<?php
/**
 * RedCross Application
 *
 * @copyright Copyright (c) 2010, Kristian Stokke Tryggestad, Rune Vikestad, Andreas Flaten Wist, Simen Nicolai Echholt, Ole Henrik Jahren
 */


class RedCross_View_Helper_PaginationLinks extends Zend_View_Helper_Abstract
{

    public function paginationLinks($paginator, array $query = null)
    {
        if ($query !== null) {
            $query = $this->_formatQuery($query);
        }

        $this->view->addScriptPath(APPLICATION_PATH . '/layouts/main/pagination/');
        return $this->view->paginationControl($paginator, 'Sliding', 'controls.phtml', array('query' => $query));
    }

    private function _formatQuery(array $query)
    {
        $queryString = '?';
        foreach($query as $q => $c) {
            $queryString .= $q . '=' . $c . '&';
        }
        return substr($queryString, 0, -1);
    }

}
